package com.hxkj.service;

import com.alicp.jetcache.anno.CacheInvalidate;
import com.github.pagehelper.PageInfo;
import com.hxkj.domain.po.AllocationSite;
import com.hxkj.domain.po.AuthUser;
import com.hxkj.domain.po.Site;
import com.platform.common.domain.result.ResultDataStruct;
import com.platform.common.domain.result.ResultMessageStruct;
import com.platform.common.domain.to.PageTo;

import java.util.List;

/**
 * 站点Service
 * <p>
 * Created by zzx on 2018/5/19.   List<Site>
 */
public interface AuthSiteService {

    /**
     * 从缓存中获取数据
     *
     * @param
     * @return
     * @throws Exception
     */
    //@Cached(name="siteCache", key="#site.siteId", expire = 3600,cacheType = CacheType.REMOTE)
    PageInfo<Site> getSiteList(Site site, PageTo pageParam) throws Exception;

    /**
     * 获取切换站点列表
     *
     * @param
     * @return
     * @throws Exception
     */
    //@Cached(name="siteCache", key="#site.siteId", expire = 3600,cacheType = CacheType.REMOTE)
    ResultDataStruct getSwitcherList(Site site) throws Exception;

    /**
     * 从缓存中获取数据
     *
     * @param site
     * @return
     * @throws Exception
     */
    //@Cached(name="siteCache", key="#site.siteId", expire = 3600,cacheType = CacheType.REMOTE)
    ResultDataStruct getSiteFromCache(Site site) throws Exception;


    /**
     * 更新用户缓存
     *
     * @param site
     */
    //@CacheUpdate(name="siteCache.", key="#site.siteId", value="#Site")
    void updateSite(Site site) throws Exception;

    /**
     * 删除用户缓存
     * 批量软删除站点信息
     *
     * @param site
     */
    @CacheInvalidate(name = "siteCache.", key = "#site.siteId")
    ResultMessageStruct deleteSite(Site site) throws Exception;

    /**
     * 增加站点
     *
     * @param site
     */
    ResultMessageStruct saveSite(Site site) throws Exception;


    /**
     * 从缓存中获取数据
     *
     * @param siteId
     * @return
     * @throws Exception
     */
    // @Cached(name="siteCache", key="#siteId", expire = 3600,cacheType = CacheType.REMOTE)
    //  @CacheRefresh(refresh = 1800, stopRefreshAfterLastAccess = 3600, timeUnit = TimeUnit.SECONDS)
    Site getSiteRefresh(Long siteId) throws Exception;

    /**
     * @return int
     * @author Mr.zheng
     * @Description saveUserSite 添加删除修改用户管理站点
     * @Date 19:36 2018/5/21
     * @Param [uid, siteIds] 用户uid和站点Id拼接字符串
     **/
    ResultMessageStruct saveUserSite(AuthUser authUser) throws Exception;

    /**
     * @return com.github.pagehelper.PageInfo
     * @author Mr.zheng
     * @Description getUserSiteList 根据用户ID获取其管理的站点
     * @Date 17:48 2018/5/21
     * @Param [uid]
     **/
    ResultDataStruct<AllocationSite> getUserSiteList(Long uid) throws Exception;

    /**
     * 站点排序
     *
     * @param site
     */
    ResultMessageStruct SiteSort(Site site) throws Exception;

    List<Site> getList(Site site) throws Exception;

    String getSiteLogo(Long siteId) throws Exception;

    /**
     * 站点信息包括站点的类型名称
     *
     * @param site
     * @return 符合条件的Site对象List
     */
    List<Site> getSiteInfoList(Site site, PageTo pageParam);
}
